package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.DeptDividedMapperExt;
import com.lzy.product.dtos.DeptDividedDto;
import com.lzy.product.entity.DeptDivided;
import com.lzy.product.service.DeptDividedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DeptDividedServiceImpl implements DeptDividedService {
    @Autowired
    DeptDividedMapperExt deptDividedMapperExt;

    @Override
    public Long insert(DeptDividedDto dto) {
        DeptDivided deptDivided = DozerUtils.map(dto, DeptDivided.class);
        return deptDividedMapperExt.insertSelective(deptDivided) > 0 ? deptDivided.getId() : 0;
    }

    @Override
    public Boolean update(DeptDividedDto dto) {
        return deptDividedMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, DeptDivided.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public DeptDividedDto findById(Long id) {
        return DozerUtils.map(deptDividedMapperExt.selectByPrimaryKey(id), DeptDividedDto.class);
    }

    @Override
    public List<DeptDividedDto> query(DeptDividedDto dto) {
        return null;
    }


    @Override
    public DeptDividedDto findByDeptId(Long id) {
        return deptDividedMapperExt.findByDeptId(id);
    }

    @Override
    public Boolean updateByDeptId(DeptDividedDto dividedDto) {
        return deptDividedMapperExt.updateByDeptId(dividedDto) > 0;
    }
}
